package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.CommentManagerIdDTO;
import com.heima.model.wemedia.dtos.CommentManagerDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(value = "评论管理API", tags = "评论管理API")
@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @ApiOperation("保存评论信息")
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody @Validated CommentSaveDTO dto) {
        return commentService.saveComment(dto);
    }

    @ApiOperation("保存评论点赞")
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDTO dto) {
        return commentService.like(dto);
    }

    @ApiOperation("加载文章评论列表")
    @PostMapping("/load")
    public ResponseResult findByArticleId(@RequestBody CommentDTO dto) {
        return commentService.findByArticleId(dto);
    }

    @PostMapping("/list")
    @ApiOperation("自媒体评论管理")
    public ResponseResult commentManager(@RequestBody CommentManagerDTO dto) {
        return commentService.commentManager(dto);
    }

    @ApiOperation("评论点赞")
    @PostMapping("/likings")
    public ResponseResult liking(@RequestBody CommentManagerIdDTO dto) {
        return commentService.liking(dto);
    }

    @ApiOperation("评论回复")
    @PostMapping("/add")
    public ResponseResult add(@RequestBody CommentManagerRepayDTO dto) {
        return commentService.add(dto);
    }

    @ApiOperation(("评论置顶"))
    @PutMapping("/changeTop")
    public ResponseResult changeTop(@RequestBody CommentManagerIdDTO dto) {
        return commentService.changeTop(dto);
    }

    @ApiOperation(("删除评论"))
    @PostMapping("/delete")
    public ResponseResult delete(@RequestBody CommentManagerIdDTO dto) {
        return commentService.delete(dto);
    }
}